<% layout('/layouts/default.html', {title: '用户管理', libs: ['validate','dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-people"></i> ${empUser.isNewRecord ? '新增用户' : op == 'auth' ? '用户授权角色' : '编辑用户'}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${empUser}" action="${ctx}/sys/empUser/save" method="post" class="form-horizontal">
			<#form:hidden name="op" value="${op}"/>
			<#form:hidden name="userType" value="employee"/>
			<#form:hidden path="userCode"/>
			<#form:hidden path="userName"/>

			<div class="box-body">
				<% if(op=='auth'){ %><br/><% } %>

				<div class="form-unit">基本设置</div>


				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> 姓名：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.empName" maxlength="32" class="form-control required"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> 身份证：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.cardNo" maxlength="32" class="form-control required"/>
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> 登录账号：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden name="oldLoginCode" value="${empUser.loginCode}"/>
								<#form:input path="loginCode" minlength="4" maxlength="20" readonly="${op=='auth'}"
									class="form-control required userName"
									remote="${ctx}/sys/user/checkLoginCode?oldLoginCode=${empUser.loginCode}"
									data-msg-remote="登录账号已存在"/>
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 出生日期：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.birthday" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> 性别：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="sex" dictType="sys_user_sex"  class="form-control required "/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 民族：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="employee.nation" dictType="sys_user_nation"  class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 学历：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="employee.education" dictType="emp_education"  class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">单位信息</div>
				<% if(op == 'add' || op == 'edit') { %>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> 部门：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="office" title="部门"
								path="employee.office.officeCode" labelPath="employee.office.officeName"
								url="${ctx}/sys/office/treeData" class="required" allowClear="false"/>
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('机构')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="company" title="${text('机构选择')}"
										path="employee.company.companyCode" labelPath="employee.company.companyName"
										url="${ctx}/sys/company/treeData" btnClass="" allowClear="true" readonly="${utype=='employee'}" />
							</div>
						</div>
					</div>

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 工号：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.empNo" maxlength="32"  class="form-control abc"/>
							</div>
						</div>
					</div>
				</div>

				<div class="row">

					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 专业：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.major" maxlength="32" class="form-control "/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 所在岗位：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select multiple="true" path="employee.employeePosts" items="${postList}"
								itemLabel="postName" itemValue="postCode" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 职称：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.rank" maxlength="32" class="form-control "/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 聘用日期：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.joinTime" dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 离职日期：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.quitTime" dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 劳动是否已签：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="employee.isSign" dictType="sys_yes_no"  class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 到期日期：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.expireTime" dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 经纪人资格证：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="employee.certificate" maxlength="32" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> 备注信息：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control "/>
							</div>
						</div>
					</div>

				</div>

				<div class="form-unit">联系方式</div>


				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 手机：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<div class="input-group">
									<#form:input path="mobile" maxlength="100" class="form-control"/>
									<span class="input-group-addon"><i class="fa fa-fw fa-phone"></i></span>
								</div>
							</div>
						</div>
					</div>

                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> 固定电话：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <div class="input-group">
                                    <#form:input path="phone" maxlength="100" class="form-control"/>
                                    <span class="input-group-addon"><i class="fa fa-fw fa-phone"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>




					<!--<div class="col-xs-6">-->
						<!--<div class="form-group">-->
							<!--<label class="control-label col-sm-4" title="">-->
								<!--<span class="required hide">*</span> 投诉号码：<i class="fa icon-question hide"></i></label>-->
							<!--<div class="col-sm-8">-->
								<!--<div class="input-group">-->
									<!--<#form:input path="employee.tsTel" maxlength="100" class="form-control"/>-->

									<!--<span class="input-group-addon"><i class="fa fa-fw fa-mobile" style="margin-top:-2px;display:block;"></i></span>-->
								<!--</div>-->
							<!--</div>-->
						<!--</div>-->
					<!--</div>-->
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> 电子邮箱：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<div class="input-group">
									<#form:input path="email" maxlength="300" class="form-control email"/>
									<span class="input-group-addon"><i class="fa fa-fw fa-envelope" style="margin-top:-2px;display:block;"></i></span>
								</div>
							</div>
						</div>
					</div>
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> 证件地址：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:input path="employee.cardAddress" maxlength="200" class="form-control "/>
							</div>
						</div>
					</div>
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> 居住地址：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:input path="employee.address" maxlength="200" class="form-control "/>
							</div>
						</div>
					</div>
					<div class="col-xs-4">
						<div class="form-group">
							<label class="control-label col-sm-6" title="">
								<span class="required hide">*</span> 紧急联系人：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-6">
								<#form:input path="employee.contact" maxlength="20" class="form-control "/>
							</div>
						</div>
					</div>
					<div class="col-xs-4">
						<div class="form-group">
							<label class="control-label col-sm-6" title="">
								<span class="required hide">*</span> 关系：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-6">
								<#form:input path="employee.contactRel" maxlength="20" class="form-control "/>
							</div>
						</div>
					</div>
					<div class="col-xs-4">
						<div class="form-group">
							<label class="control-label col-sm-6" title="">
								<span class="required hide">*</span> 联系方式：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-6">
								<#form:input path="employee.contactTel" maxlength="20" class="form-control "/>
							</div>
						</div>
					</div>
				</div>

				<div class="row">

				</div>
				<% } %>
				<% if(op == 'add' || op == 'auth') { %>
				<div class="form-unit">授权角色</div>
				<div class="pl10 pb20">
					<table id="roleGrid"></table>
					<#form:hidden name="userRoleString"/>
				</div>
			    <% } %>

			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('sys:empUser:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> 关 闭</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		<% if(op == 'add' || op == 'auth') {%>
		// 获取选中角色
		$("#userRoleString").val(roleGrid.dataGrid('getSelectRows').join(','));
		var realname = $("#employee_empName").val();
		$("#userName").val(realname);
		<% } %>
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
<% if(op == 'add' || op == 'auth') {%>
// 加载角色列表
var roleGrid = $("#roleGrid").dataGrid({
	url: '${ctx}/sys/role/treeData',
	postData: [
		{name:'userType',value:'employee'},
		{name:'ctrlPermi',value:'2'}
	],
	columnModel: [
		{header:'角色名称', name:'name', sortable:false, width:100, align:"center"},
		{header:'角色编码', name:'id', sortable:false, width:100, align:"center"}  
	],
	showCheckbox: true,
	autoGridHeight: function(){
		return 'auto';
	},
	autoGridWidth: function(){
		return $('#inputForm .box-body').width()-20;
	},
	ajaxSuccess: function(){
		<% for (role in roleList!){ %>
 		roleGrid.dataGrid('setSelectRow', '${role.roleCode}');
		<% } %>
	}
});
<% } %>
</script>
